package com.wang.tool.lock.aop;

import com.wang.tool.lock.core.DynamicLockConfigCenter;
import com.wang.tool.lock.LockConfigCenter;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;

public class SpringLockConfigSetter implements ApplicationContextAware {


    @Override
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        if (applicationContext.containsBean(LockRegister.SPRING_LOCK_DYNAMIC_CONFIG_CENTER_NAME)) {
            LockConfigCenter.setDynamicConfigCenter(applicationContext.getBean(LockRegister.SPRING_LOCK_DYNAMIC_CONFIG_CENTER_NAME, DynamicLockConfigCenter.class));
        }
    }
}